Object.defineProperties(data, "name", {
    set(val) {
        // 触发操作
        input.value = val

    },
    get() {

    }
})

let proxy = new Proxy(data, {
    set(target, key, val) {
        input.value = val;
        return Reflect.set(target, key, val) // 注意// 注意
    },
    get() { }
})



// 实现add[2][3][10] + 100
const add = function createProxy(values) {
    return new Proxy(
        {},
        {
            get(target, p, reciver) {
                // 处理很后面正常的加👌
                if (p === Symbol.toPrimitive) { // 知名符号
                    return () => {
                        return values.reduce((a, b) => a + b, 0)
                    }
                }
                return createProxy([...values, +p])
            }
        }
    )
}


class ProxyStandbox {
    constructor(){
        const rawWindow = window;
        const fakeWindow = {};
        const proxy = new Proxy(fakeWindow,{
            set(target, key,val){
                target[key] = val;
                return true;
            },
            get(target,key){
                return target[key] || rawWindow[key]
            },
        })
        return proxy
    }
}
let proxy1 = new ProxyStandbox();
let proxy2 = new ProxyStandbox()
((window)=>{window.a = 'hello';consple.log(window.a)})(proxy1.proxy)
((window)=>{window.a = 'b';consple.log(window.a)})(proxy2.proxy)